﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import Engine.Managers.*;
    import Events.*;
    import Display.DialogUI.*;
    import Classes.util.*;
    import Engine.*;

    public class ImpulseBuy extends GenericDialog {

        public static const TYPE_FUEL:String = "out_of_fuel";
        public static const TYPE_COINS:String = "need_coins";
        public static const TYPE_MARKET_COINS:String = "market_coins";
        public static const TYPE_MARKET_CASH:String = "market_cash";
        public static const TYPE_MARKET_COMMODITY:String = "market_commodity";
        public static const POPUP_NAME:String = "impuseBuyMarket";

        private var m_impulseType:String;

        public function ImpulseBuy(_arg1:String){
            var _local2:String;
            this.m_impulseType = _arg1;
            switch (this.m_impulseType){
                case ImpulseBuy.TYPE_FUEL:
                    _local2 = ZLoc.t("Dialogs", "ImpulseFuel");
                    break;
                case ImpulseBuy.TYPE_COINS:
                    _local2 = ZLoc.t("Dialogs", "ImpulseCoins");
                    break;
                case ImpulseBuy.TYPE_MARKET_COINS:
                    _local2 = ZLoc.t("Dialogs", "ImpulseMarketCoins");
                    break;
                case ImpulseBuy.TYPE_MARKET_CASH:
                    _local2 = ZLoc.t("Dialogs", "ImpulseMarketCash");
                    break;
                case ImpulseBuy.TYPE_MARKET_COMMODITY:
                    _local2 = ZLoc.t("Dialogs", "ImpulseMarketCommodity");
                    break;
            };
            super(_local2, "", GenericDialogView.TYPE_YESNO, this.onClose, "", "", true);
        }
        private function onClose(_arg1:GenericPopupEvent):void{
            if (_arg1.button == GenericDialogView.YES){
                if (Utilities.isFullScreen()){
                    Utilities.setFullScreen(false);
                };
                this.onAccept();
            } else {
                if (_arg1.button == GenericDialogView.NO){
                    this.onCancel();
                };
            };
            removeEventListener(GenericPopupEvent.SELECTED, this.onClose);
        }
        protected function onAccept():void{
            switch (this.m_impulseType){
                case ImpulseBuy.TYPE_FUEL:
                    UI.displayMarketDialog("impulse_fuel", "vehicle");
                    break;
                case ImpulseBuy.TYPE_COINS:
                    FrameManager.navigateTo("money.php?ref=imp_coins");
                    break;
                case ImpulseBuy.TYPE_MARKET_COINS:
                    FrameManager.navigateTo("money.php?ref=imp_market");
                    break;
                case ImpulseBuy.TYPE_MARKET_COMMODITY:
                    FrameManager.navigateTo("money.php?ref=imp_market");
                    break;
                case ImpulseBuy.TYPE_MARKET_CASH:
                    StatsManager.count("fv_cash_buy_fail", "click_yes_please");
                    StatsManager.sendStats(true);
                    FrameManager.navigateTo("money.php?ref=tab");
                    break;
            };
        }
        protected function onCancel():void{
            switch (this.m_impulseType){
                case ImpulseBuy.TYPE_FUEL:
                    break;
                case ImpulseBuy.TYPE_COINS:
                    break;
                case ImpulseBuy.TYPE_MARKET_COINS:
                    break;
                case ImpulseBuy.TYPE_MARKET_COMMODITY:
                    break;
                case ImpulseBuy.TYPE_MARKET_CASH:
                    StatsManager.count("fv_cash_buy_fail", "click_no_thanks");
                    break;
            };
        }

    }
}//package Display 
